﻿using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;
using System.Reflection;

using System.Security;
using System.Security.Cryptography;
using System.IO;
using System.Collections;
using System.Management;

namespace Common
{
    public class ComputerInfo
    {

        public static string GetEncryptPassword(string pwd)
        {
            string pass = "";
            byte[] result = Encoding.Default.GetBytes(pwd);    //tbPass为输入密码的文本框
            MD5 md5 = new MD5CryptoServiceProvider();

            byte[] output = md5.ComputeHash(result);

            pass = BitConverter.ToString(output).Replace("-", "");

            return pass;
        }
        public static string GetHDDSerial()
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia");
            var nowstr = searcher.Get();
            foreach (ManagementObject wmi_HD in nowstr)
            { // get the hardware serial no. 
                if (wmi_HD["SerialNumber"] != null)
                {
                    string sss = wmi_HD["SerialNumber"].ToString();
                    searcher.Dispose();
                    if (sss.Length > 19)
                    {
                        sss = sss.Substring(0, 19);
                    }
                    return sss;
                }
            }
            searcher.Dispose();
            return string.Empty;
        }

      

    }

    class HardDrive
    {
        private string model = null;
        private string type = null;
        private string serialNo = null;

        public string Model
        {
            get { return model; }
            set { model = value; }
        }

        public string Type
        {
            get { return type; }
            set { type = value; }
        }

        public string SerialNo
        {
            get { return serialNo; }
            set { serialNo = value; }
        }
    }

    

}

